package com.example.travelround.mymusic.main;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.travelround.mymusic.R;

public class DetailActivity extends AppCompatActivity {

    private TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail);

        textView = (TextView) findViewById(R.id.detail_tv);

        ImageView downIV = (ImageView) findViewById(R.id.detail_down_iv);
        downIV.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        MusicBroadCast musicBroadCast = new MusicBroadCast();
        IntentFilter intentFilter = new IntentFilter("musicBroad");
        registerReceiver(musicBroadCast, intentFilter);
    }

    class MusicBroadCast extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {

            String content = intent.getStringExtra("progress");
            textView.setText(content);

        }
    }

}
